/**
 * @param {number[]} prices
 * @return {number}
 */
var maxProfit = function (prices) {
    // x,y  && x < y 收益最高,那肯定是抄底买入，然后在后面每一天都尝试卖出啊
    let min = prices[0]
    let maxPrice = 0
    for (let i = 0; i < prices.length; i++) {
        min = Math.min(prices[i], min)
        maxPrice = Math.max(prices[i] - min, maxPrice)
    }
    return maxPrice
};


console.log(maxProfit([7, 1, 5, 3, 6, 4]))